<?php  if ( ! defined('CentPHP')) exit( "Disallow to access direct!" );
/*
    |====================================================|
	|  CentPHP                                           |
	|----------------------------------------------------|
	|  package      lib/kernel/Class.URI.php                |
	|  auther       Boyu Sun                             |
	|  copyright    Copyright (c) 2008, sunboyu.cn       |
	|  license      freebsd-license                      |
	|  link         www.sunboyu.cn                       |
	|  version      Version 0.1                          |
	|====================================================|
*/

/*
    +-------------------------------------------------------------------
	| class URI
	| Parses URIs.
	+-------------------------------------------------------------------
*/

class URI
{
	var $module  = '';
	var $action  = '';
	var $get     = array();
	var $post    = array();
	var $session = array();
	var $cookie  = array();
    /*
	 *  Constructer
	 *  @param null
	 *  @retrun null
	 */
	function __construct()
	{
	    $this->_init();
	}
    /*
	 *  Change some global vars into object
	 *  @param null
	 *  @retrun null
	 */
	function _init()
	{
		$this->get = &$_GET;
		foreach( $_GET as $key => $value )
		{
			$this->get[$key] = htmlspecialchars( $value , ENT_QUOTES );
		}
        $this->post = &$_POST;
		foreach( $_POST as $key => $value )
		{
			$this->post[$key] = htmlspecialchars( $value , ENT_QUOTES );
		}
        $this->session = &$_SESSION;
		foreach( $_SESSION as $key => $value )
		{
			$_SESSION[$key] = htmlspecialchars( $value , ENT_QUOTES );
		}
		$this->cookie = &$_COOKIE;
		foreach( $_COOKIE as $key => $value )
		{
			$_COOKIE[$key] = htmlspecialchars( $value , ENT_QUOTES );			
		}
	}
	/*
	 *  Return the module
	 *  @param null
	 *  @retrun null
	 */
	function get_module()
	{
	    return isset($this->get['module']) ? $this->get['module'] : 'welcome';
	}
	/*
	 *  Return the action
	 *  @param null
	 *  @retrun null
	 */
	function get_action()
	{
	    return isset($this->get['action']) ? $this->get['action'] : 'index';
	}
}
?>